package DataBases;
import java.util.Iterator;
import java.util.Vector;

public class DBToxicNotification {
	
	private static DBToxicNotification instance = null;
	private Vector<ToxicNotificationObject> dB;
	
	
	private DBToxicNotification(){
		dB = new Vector<ToxicNotificationObject>();
	}	
	
	public static DBToxicNotification getInstance(){
		if(instance==null){
			instance = new DBToxicNotification();
		}
		return instance;
	}

	public void addItem(ToxicNotificationObject item){
		//System.out.println("Notification: " + item.getHours() + " "+ item.getMinutes() + " "+ item.getSeconds() + " " + item.getOrigen());
		dB.add(item);		
	}
	
	public boolean exists(ToxicNotificationObject notification){
		ToxicNotificationObject aux;
		Iterator<ToxicNotificationObject> itr = dB.iterator();
		while(itr.hasNext()){
			aux = itr.next();
			if(aux.getOrigen().compareTo(notification.getOrigen())==0){				
				if (aux.getHours() == notification.getHours() && aux.getMinutes() == notification.getMinutes() && aux.getSeconds() == notification.getSeconds()){
					itr.remove();
					return true;		
				}				
			}
		}
		return false;
	}

}
